class Solution(object):
    def numSub(self, s):
        ans = 0
        left = 0
        right = 0
        n = len(s)
        while right < n:
            if s[right] == '1':
                ans += right - left + 1
            else:
                left = right + 1
            right += 1
        return ans % (10 ** 9 + 7)
